package se.webbzon.oschi01.sound;

import java.io.IOException;
import java.net.URL;

import javazoom.jl.decoder.JavaLayerException;

public class MP3Source implements FiniteSoundSource  {
	
	// The URL to the mp3 file
	private final URL url;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public MP3Source(URL url) {
		this.url = url;
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Returns the URL to the mp3 file. **/
	public URL getURL() {
		return url;
	}

	@Override public FiniteSound createSound() throws SoundException {
		try {
			return new MP3Sound(url);
		} catch (JavaLayerException | IOException e) {
			throw new SoundException(e);
		}
	}

}
